<script language="javascript" type="text/javascript">

    function getValueSingle(kode, nama) {
        try {
            parent.parent._obj_fSendValue(kode, nama, 'nik', 'nama');
        }
        catch(e) { alert(e.message); }
        parent.parent.focus();

<?php echo CloseGB(false); // close grebox  ?>

    }

    function detil(kode){
        return GB_showCenter('Detil Karyawan', '<?php echo base_url(); ?>index.php/management/data_karyawan_detil/'+ kode, 520, 850);
    }

    function removeData(kode) {

        if(confirm('Anda yakin akan menghapus data ini?')) {
            location.href = '<?php echo base_url() ?>index.php/management/data_karyawan_delete/' + kode;
        }
    }

    function exportData(){
        location.href = '<?php echo base_url() ?>index.php/management/data_karyawan/exp';
    }

</script>


<?php
?>
<div id="content">

    <div id="content2">
        <div class="DivTable">
            <table class="GridTable">
                <tr>
                    <td colspan="21" class="noborder"><div class="box-control"></div></td>
                </tr>
                <tr class="GridHeader">
                    <td width="20">No.</td>
                    <td width="300">Title</td>
                    <?php $divisis = $this->db->query("SELECT * FROM mt_divisi ORDER BY divisi ASC") ?>
                    <?php foreach ($divisis->result() as $divisi): ?>
                    <td><?php echo $divisi->divisi_sname ?></td>
                    <?php endforeach; ?>
                    <td>Jumlah Karyawan</td>
                </tr>
                <tr class="GridItem1">
                    <td width="20">1</td>
                    <td>Resume Data Karyawan</td>
                    <?php foreach ($divisis->result() as $divisi): ?>
                    <td><?php echo $this->data_karyawan->get_scalar("SELECT COUNT(nik) AS total FROM mt_karyawan WHERE id_divisi = $divisi->id_divisi", "total") ?></td>
                    <?php endforeach; ?>
                    <td style="text-align:center"><?php echo $this->data_karyawan->get_scalar("SELECT COUNT(nik) AS total FROM mt_karyawan", "total") ?></td>
                </tr>
            </table>
        </div>
        <br class="bersih" />
    </div>
    <div class="DivTable">

        <form name="fCari" id="fCari" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" >

            <table class="GridTableFilter">
                <?php
                echo $fp;
                ?>
                <tr>
                    <td>
                        <?php
                        echo $fp2;
                        ?>
                    </td>
                </tr>
            </table>
            <!--        </form>-->
            <?php
            echo form_close();
            ?>

            <table class="GridTable" style="width:100%">
                <tr>
                    <td colspan="8" class="noborder">
                        <div class="box-control">
                            <?php
                            echo "<a href=\"#\" onclick=\"javascript:exportData()\" class=\"report\" title=\"Export Data\">&nbsp;</a>";
                            echo Greybox::createLink(base_url() . "index.php/management/data_karyawan_edit/", "", "Tambah Data", "add");
                            echo "<a href=\"" . $_SERVER["PHP_SELF"] . "\" class=\"refresh\" title=\"Muat Ulang\">&nbsp;</a>";
                            ?>
                        </div>
                    </td>
                </tr>
                <tr class="GridHeader">
                    <td>No.</td>
                    <td></td>
                    <td>NIK</td>
                    <td>Nama Karyawan</td>
                    <td>Divisi</td>
                    <td>No.HP</td>
                    <td>No.Telp</td>
                    <td>Email</td>
                </tr>
                <?php
                if ($numRows > 0) {
                    $nomor = $post['offset'];
                    foreach ($result as $row) {
                        $nomor++;
                        $kodecontent = $row->nik;
                        $styleTR = "GridItem1";
                        ?>
                <tr class="<?php echo $styleTR; ?>" >
                    <td onclick="javascript:detil('<?php echo $kodecontent; ?>')"><?php echo $nomor; ?></td>
                    <td><?php
//                    $gb->createLink($__CFG_http_root . "index.php/management/karyawan_edit/" . $kodecontent . "", "", "Ubah Data Karyawan", "edit", "", 850, 520);
                                echo Greybox::createLink(base_url() . "index.php/management/data_karyawan_edit/" . $kodecontent . "", "", "Ubah Data Karyawan", "edit", "", 850, 520);
                                echo "<a href=\"#\" class=\"delete\" title=\"Hapus Data\" onclick=\"javascript:removeData('" . $kodecontent . "')\">&nbsp;</a>";
                                ?></td>
                    <td onclick="javascript:detil('<?php echo $kodecontent; ?>')"><?php echo $row->nik; ?></td>
                    <td onclick="javascript:detil('<?php echo $kodecontent; ?>')"><?php echo $row->nama; ?></td>
                    <td><?php echo $row->divisi; ?></td>
                    <td><?php echo $row->no_hp; ?></td>
                    <td><?php echo $row->no_telepon; ?></td>
                    <td><?php echo $row->email; ?></td>
                </tr>
                        <?php
                    }
                } else {
                    ?>
                <tr class="GridItem1">
                    <td colspan="8">Tidak ada data</td>
                </tr>

                    <?php
                }
                ?>
            </table>
    </div>
    <?php echo $paging['pagingView']; ?>
    <br class="bersih" />
</div>

<script type="text/javascript">

    function openURL(url) {
        open(''+ url +'', 'wndStaff', 'width=730,height=500,directories=0,location=0,resizable=1,scrollbars=1,toolbar=0,copyhistory=0,status=0');
        return false;
    }

    jQuery(document).ready(function(){

        jQuery(".tr_slide").hide();

        jQuery('.search').click(
        function(){
            jQuery(".tr_slide").slideToggle();
        }
    );
    });

</script>

<script language="javascript">


    jQuery(document).ready(function(){
        jQuery(".tr_slide").hide();

        jQuery('.search').click(
        function(){
            jQuery(".tr_slide").slideToggle();
        }
    );

    });

</script>